import Vue from 'vue';
// 1、导入
import VueRouter from 'vue-router';
// 2、模块化机制，使用Router
Vue.use(VueRouter)
import Home from '@/views/Home';
import About from '@/views/About';
import User from '@/views/User';

// 3、创建路由器对象
const router = new VueRouter({
  mode:'history', //历史模式，干净的网页地址
  routes:[
    {
      path: '/',
      // 路由重定向
      // redirect: '/home',
      redirect: {name:"home"},
    },
    {
      path: "/home",
      name: 'home',
      component: Home
    },
    {
      path: '/about',
      name: 'about',
      component: About
    },
    {
      path: '/user/:id',
      name: 'user',
      component: User,
      props: true,
    },
    {
      path: '/page',
      name:  'page',
      component: ()=> import('@/views/Page'),
      alias:'/aaa',  // 路由起别名命名
    },
    {
      path: '/user-*',
      component: () => import('@/views/User-admin')
    },
    {
      path:'/notes',
      name: 'notes',
      component: ()=>import('@/views/Notes'),
    },
    {
      path: '/blog',
      name: 'blog',
      component: ()=>import('@/views/Blog'),
      meta:{
        // 加到黑名单
        requireAuth:true
      }
    },
    {
      path:'/login',
      name: 'login',
      component: ()=>import('@/views/Login'),
    },
    {
      path:'eaditor',
      name:'eaditor',
      component:()=>import('@/views/Eaditor')
    },
    {
      path: '*',
      // 局部导入，异步加载组件
      component: () => import('@/views/404')
    },
  ]
})
// 4、抛出路由对象
export  default router;